import DList from "@/components/dlist";
export default {
    data() {
      return {
        name: "",
        listData:[],
        loading: false,
        finished: false,
        page: 1,
      }
    },
    activated() {
      this.name = this.$route.params.name;
      this.fun.setWXTitle(this.$route.params.name);
      this.listData = [];
      this.loading = false;
      this.finished = false;
      this.page = 1;
      this.getData();
    },
    methods: {
      async getData() {
        let url = this.name == '存货明细' ? "plugin.stock-service.frontend.controllers.stock.logs" : this.name == '代销明细' ? "plugin.stock-service.frontend.controllers.help.logs" : ''
        if (this.loading === true || this.finished === true) {
          return;
        }
        this.loading = true;
        let {data,result,msg} = await $http.post(url,{page:this.page});
        if (result === 0) {
          this.$toast(msg);
          return;
        }
        if (data.list.data.length === 0 || data.list.data.length < data.list.per_page || data.list.current_page === data.list.last_page) {
          this.finished = true;
        }
        this.listData.push(...data.list.data);
        this.page++;
        this.loading = false;
      },
      onLoad(){
        this.getData();
      }
    },
    components: {
      DList
    },
  };
  